﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZDSoft.QLMS.Entity;
using NHibernate.Criterion;

namespace ZDSoft.QLMS.Component
{
    public class ComponentBase<T>
    {
        EntityBase<T> dalEntity = new EntityBase<T>();

        //查询所有
        public IList<T> FindAll()
        {
            return dalEntity.FindAll();
        }

        //通过ID查找实体
        public T FindByID(int id)
        {
            return dalEntity.FindByID(id);
        }

        //创建
        public void Create(T t)
        {
            dalEntity.Create(t);
        }

        //修改
        public void Edit(T t)
        {
            dalEntity.Edit(t);
        }

        //删除
        public void Delete(int id)
        {
            dalEntity.Delete(id);
        }

        //分页获取对象集合
        public IList<T> GetPaged(IList<ICriterion> queryConditions, IList<Order> orderList, int pageIndex,
            int pageSize, out int count)
        {
            return dalEntity.GetPaged(queryConditions, orderList, pageIndex, pageSize, out count);
        }

        //根据查询条件获取所有满足条件的实体
        public IList<T> Find(IList<ICriterion> queryConditions)
        {
            return dalEntity.Find(queryConditions);
        }
    }
}
